package com.sx.micowell.module.user.writeInfo

import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.mvvm.base.data.DataBindingConfig
import com.gyf.immersionbar.ImmersionBar
import com.sx.micowell.BR
import com.sx.micowell.R
import com.sx.micowell.databinding.ActWriteHeightBinding
import com.sx.micowell.databinding.ActWriteWeightBinding
import com.sx.micowell.framework.app.IntentKey
import com.sx.micowell.framework.app.MyActivity
import com.sx.micowell.framework.arouth.RouteManager
import com.sx.micowell.framework.arouth.RoutePath.Companion.WRITE_WEIGHT
import com.sx.micowell.framework.model.PhysicalInfoModel
import kotlinx.android.synthetic.main.act_write_weight.*

/**
 * @Description
 * @Author 梁浩文
 * @Date 2021/7/30 18:13
 */
@Route(path = WRITE_WEIGHT)
class WriteWeightActivity  : MyActivity<ActWriteWeightBinding>() {

    @Autowired(name = IntentKey.TYPE)
    @JvmField
    var type: String = ""

    @Autowired(name = IntentKey.DATA)
    @JvmField
    var date: String = ""

    @Autowired(name = IntentKey.KEY)
    @JvmField
    var height: String = ""

    private var viewMode: PhysicalInfoModel?=null

    override fun getDataBindingConfig(): DataBindingConfig = DataBindingConfig(R.layout.act_write_weight,BR.viewModel,viewMode)

    override fun initViewModel() {
        super.initViewModel()
        viewMode=getActivityScopeViewModel(PhysicalInfoModel::class.java)
    }

    override fun initView() {
        ImmersionBar.with(this).statusBarDarkFont(true)
            .fitsSystemWindows(true).init()
        weight_init.currentValue = 50f
        weight_target.currentValue = 50f

        weight_init.setOnValueChangedListener {
            viewMode!!.initWeightData.postValue(it.toString())
            weight_init.currentValue = it
        }
        weight_target.setOnValueChangedListener {
            viewMode!!.targetWeightData.postValue(it.toString())
            weight_target.currentValue = it
        }

        binding.tvNext.setOnClickListener {
            RouteManager.getInstance().intentToTarget(type, date, height,
                weight_init.currentValue.toString(),  weight_target.currentValue.toString())
        }
    }

    override fun initData() {

    }
}